﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PowersourceUIToolkit;
using UCL.Powersource;
using UCL.Powersource.Mock;
using UCL.Powersource.TFS;

namespace Powersource_UnitTests
{
    public static class TestManager
    {

        public enum Configurations
        {
            AllDummies,
            DummyDTEOnly,
            DummyDTEAndUI

        }

        private static DummyPowersourceBootStrapper ActiveBootStrapper;

        public static DummyPowersourceBootStrapper ConfigureNewBootStrapperForTest(Configurations test,string[] ExtensibilityFiles=null)
        {
            if (ActiveBootStrapper != null && !ActiveBootStrapper.IsDisposed) throw new InvalidProgramException("There is an active bootstrapper from previous tests. You cannot proceed, unless bootstrapper are correctly disposed at the edn of the test");
            var bs = new DummyPowersourceBootStrapper();
            bs.TypesToLoad = new Type[] { typeof(DummyStatistic1), typeof(PowersourceToolWindow) };
            bs.SetExtensibilityFiles(ExtensibilityFiles);
            bs.StatisticManager = new StatisticManager();
            bs.StatisticManagerQueue = new StatisticManagerQueue();
            bs.RemoteBuilderQueue = new RemoteBuilderQueue();
            bs.Initialize();
            ActiveBootStrapper = bs;
            return bs;
            
        }

        public static void DisposeBootStrapper()
        {
            if (ActiveBootStrapper != null)
            {
                ActiveBootStrapper.Dispose();
                ActiveBootStrapper = null;
            }
        }
    }
}
